<?php
/**
 * Created by jinqiang on 2024/12/18 11:13.
 * Copyright (c) 2024, Your Company. All rights reserved.
 */


namespace App\Http\Controllers\Callback;


use App\Http\Controllers\Controller;
use App\Http\Services\Callback\ShujiaService;
use Illuminate\Http\Request;

class ShujiaController extends Controller
{
    //数加系统 同步按钮触发接口（废弃）
    public function processingSync(Request $request, ShujiaService $shujiaService)
    {
        $this->validate($request, [
            'partnerid' => 'required|in:9740853d6af8db38fc15e82fdd97dd10',
            'method' => 'required|in:ProcessingOrderUpload(废弃)',
            'partnerkey' => 'required',
            'token' => 'required',
            'sing' => 'required',
            'parameter' => 'required'
        ]);
        $param = $request->all();
        info("加工单同步", [$param]);
        $sign = md5($param['method'].$param['partnerid'].$param['token'].$param['partnerkey']);
        if($sign != $param['sing']){
            return error("sign签名错误");
        }
        $res = $shujiaService->processingSync($param['parameter']);
        return $res['code'] === 0 ? success("同步成功") : error($res['msg'], $res);
    }
}
